import React from "react";
import { Route, NavLink, Switch, Redirect } from "react-router-dom";

import Header from "./components/Header";
import Home from "./pages/Home/index";
import About from "./pages/About";
import Help from "./pages/Help";
import Detail from "./pages/Detail";

function App() {
  return (
    <div className="app">
      <Header a="1" b="2" />
      <div className="main">
        <div className="left">
          <NavLink className="link" to="/home" activeClassName="hello">
            Home
          </NavLink>
          <NavLink className="link" to="/about" activeClassName="hello">
            About
          </NavLink>
          <NavLink className="link" to="/help" activeClassName="hello">
            Help
          </NavLink>
        </div>
        <div className="right">
          <Switch>
            <Route path="/home" component={Home} />
            <Route path="/about" component={About} />
            <Route path="/help" component={Help} />
            {/*
              1. params 方式
                Route 的 path 需要占着 坑
            */}
            {/* <Route path="/detail/:id" component={Detail} /> */}

            {/* 
              2. search 方式（？号方式）
                Route 的 path 不需要占着 坑
            */}
            {/* <Route path="/detail" component={Detail} /> */}

            {/* 
              3. state 方式
                Route 的 path 不需要占着 坑
            */}
            <Route path="/detail" component={Detail} />
          </Switch>
        </div>
      </div>
    </div>
  );
}

export default App;
